package io;

import java.io.*;

/**
 * 在流连接中使用PW
 */
public class PWDemo2 {
    public static void main(String[] args) throws FileNotFoundException, UnsupportedEncodingException {
        //低级流，负责向文件中写入字节
        FileOutputStream fos = new FileOutputStream("pw2.txt");
        //转换流(高级流),负责衔接字符与字节流，将写出的字符转换为字节
        OutputStreamWriter osw = new OutputStreamWriter(fos,"UTF-8");
        //缓冲流(高级流),负责块写文本数据加速
        BufferedWriter bw = new BufferedWriter(osw);
        //PW(高级流)按行写出字符串，自动行刷新
        PrintWriter pw = new PrintWriter(bw);

        pw.println("你好!");
        pw.println("再见!");

        System.out.println("写出完毕!");
        pw.close();
    }
}







